package com.oig.sys.workflow.service.impl;

import com.oig.sys.workflow.dao.ITbAutoExeLogDao;
import com.oig.sys.workflow.dto.AutoExeLogDto;
import com.oig.sys.workflow.entity.TbAutoExeLog;
import com.oig.sys.workflow.service.ITbAutoExeLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wuxl
 */
@Slf4j
@Service
public class TbAutoExeLogServiceImpl implements ITbAutoExeLogService {

	private final ITbAutoExeLogDao tbAutoExeLogDao;

	@Autowired
	public TbAutoExeLogServiceImpl(ITbAutoExeLogDao tbAutoExeLogDao){
		 this.tbAutoExeLogDao = tbAutoExeLogDao;
	}

	@Transactional
	@Override
	public void addAutoExeLog(AutoExeLogDto autoExeLogDto){
		TbAutoExeLog autoExeLog = new TbAutoExeLog();
		BeanUtils.copyProperties(autoExeLogDto, autoExeLog, "id");
		this.tbAutoExeLogDao.save(autoExeLog);
	}

	/**
	 * log先不删
	 */
	@Transactional
	@Override
	public void delAutoExeLog(Integer ruleId) {
		this.tbAutoExeLogDao.deleteByRuleId(ruleId);
	}
}
